using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using ConfeccionesJR.Entites;

namespace ConfeccionesJR.Repository.Mapping
{
    public class MATERIALMap : EntityTypeConfiguration<MATERIAL>
    {
        public MATERIALMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            this.Property(t => t.Descripcion)
                .IsRequired()
                .HasMaxLength(250);

            // Table & Column Mappings
            this.ToTable("MATERIAL");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Descripcion).HasColumnName("Descripcion");
            this.Property(t => t.Stock).HasColumnName("Stock");

            // Relationships
            this.HasRequired(t => t.UNIDAD_MEDIDA)
                .WithMany(t => t.MATERIALs)
                .HasForeignKey(d => d.unidadMedidaId);
                //WillCascadeOnDelete(false); 
        }
    }
}
